<template>
    <view class="page-wrap">
        <view class="home_tip">
            <!-- 轮播图 -->
            <swiper @tap.stop.prevent="onSwiperTap" indicator-color="#FFFFFF" indicator-active-color="#FF8722"
                :indicator-dots="true" :autoplay="true" interval="5000" :circular="true">
                <block v-for="(item, index) in banners" :key="index">
                    <swiper-item>
                        <image :src="item.pic" :data-id="item.specialActivityId" @tap="toDetails" :data-item="item">
                        </image>
                    </swiper-item>
                </block>
            </swiper>
            <view class="mantle flexs align-center justify-center text-white flex-direction" v-if="show">
                <block v-if="authtype == 0">
                    <view class="text-lg">审核中</view>
                    <view class="text-sm margin-tb margin-lr padding-lr-xl text-center">
                        审核时间需要1-3个工作日，审核期间不能接受订单，先去完善门店资料把！</view>
                    <!-- <view class="mantle_btn padding-tb-xs radius padding-lr-sm text-xs margin-bottom-xl" catchtap="getauthbaseindex">完善门店</view> -->
                </block>
                <block v-if="authtype == -1">
                    <view class="text-lg">审核失败</view>
                    <view class="text-sm margin-tb margin-lr padding-lr-xl text-center">抱歉，您的门店申请没有通过，请重新提交申请！</view>
                    <view class="mantle_btn padding-tb-xs radius padding-lr-sm text-xs margin-bottom-xl"
                        @tap.stop.prevent="goauthindex">重新申请</view>
                </block>
                <block v-if="authtype == 1">
                    <view class="text-lg">审核通过</view>
                    <view class="text-sm margin-tb margin-lr padding-lr-xl text-center">恭喜！您的门店申请已通过，快去邀请美发师加入吧！</view>
                    <view class="mantle_btn padding-tb-xs radius padding-lr text-xs margin-bottom-xl"
                        @tap.stop.prevent="getshow">确认</view>
                </block>
            </view>
        </view>
        <!-- 订单类别 -->
        <view class="home_order">
            <view class="home_order_1" @tap="onOrderListTap" data-order-status="one">
                <text class="index-title">{{ pendingSum }}</text>
                <text class="index-content">待接单</text>
            </view>
            <view class="home_order_1" @tap="onOrderListTap" data-order-status="two">
                <text class="index-title">{{ acceptAndServiceSum }}</text>
                <text class="index-content">待核销</text>
            </view>
            <view class="home_order_1" @tap="onOrderListTap" data-order-status="three">
                <text class="index-title">{{ successSum }}</text>
                <text class="index-content">已完成</text>
            </view>
            <view class="home_order_1" @tap="onOrderListTap" data-order-status="four">
                <text class="index-title">{{ refundSum }}</text>
                <text class="index-content">已退款</text>
            </view>
        </view>
        <view class="home_list">
            <view class="home_row">
                <view class="home_hair" @tap="onMyStylistsTap">
                    <text>我的美发师</text>
                    <image :src="shopimgUrl + '1.png'"></image>
                </view>
                <view class="home_hair1">
                    <view class="home_shop" style="background-color: #feeeef" @tap="goCheckstand">
                        <text>收银台</text>
                        <image src="https://yiyue-store-applet.oss-cn-shenzhen.aliyuncs.com/icon_uw.png"></image>
                    </view>
                    <view class="home_shop" style="background-color: #ddecff" @tap="getcode">
                        <text>扫一扫</text>
                        <image :src="shopimgUrl + '10.png'"></image>
                    </view>
                </view>
            </view>
            <view class="home_row1">
                <view class="home_shop" style="background-color: #e5f8f6" @tap="onOrderTap">
                    <text>预约管理</text>
                    <image :src="shopimgUrl + '3.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #ffeee6" @tap="onTimeTap">
                    <text>时间管理</text>
                    <image :src="shopimgUrl + '4.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #f0edff" @tap="onSeatTap">
                    <text>卡位管理</text>
                    <image :src="shopimgUrl + '9.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #eff8ea" @tap="onMarketTap">
                    <text>助理/耗材</text>
                    <image :src="shopimgUrl + '5.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #ecf9fe" @tap="onPersonTap">
                    <view class="home_shop1">
                        <text>当面付</text>
                        <text style="font-size: 28rpx">(烫染护耗材)</text>
                    </view>
                    <image :src="shopimgUrl + '6.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #feeeef" @tap="onInvitationTap">
                    <text>邀请美发师</text>
                    <image :src="shopimgUrl + '7.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #fff3e9" @tap="onEvaluationTap">
                    <text>评价管理</text>
                    <image :src="shopimgUrl + '8.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #e5f8f6" @tap="onMealTap">
                    <text>套餐包</text>
                    <image :src="shopimgUrl + '11.png'"></image>
                </view>
                <view class="home_shop" style="background-color: #f1f7e9" @tap="onCruiseShop">
                    <text>巡店</text>
                    <image src="https://yiyue-store-applet.oss-cn-shenzhen.aliyuncs.com/cruiseshop.png"></image>
                </view>
                <view class="home_shop" style="background-color: rgb(249, 239, 222)" @tap="onShopManagerTap">
                    <text>门店管理</text>
                    <image :src="shopimgUrl + '2.png'"></image>
                </view>
            </view>
            <!-- 切换版本 -->
            <view class="switch-versions">
                <image class="switch-versions-iamge"
                    src="https://yiyuestore.oss-cn-shenzhen.aliyuncs.com/store/2022/12/30/fe0e524c90465014ac59412b2558af2e.png">
                </image>
                <text class="switch" @tap="switchNewHome">立即切换</text>
            </view>
        </view>

        <!-- 核销 -->
        <van-overlay :show="showoCode" @click="onClickCodeHide" z-index="99">
            <view class="codebox" @tap.stop.prevent="onClickCodeHide">
                <view class="codewrapperbox" @tap.stop.prevent="shop">
                    <view class="code-hairmsg">
                        <view class="hairmsg-name">{{ orderDetails?orderDetails.userNickname : '' }}</view>
                        <!-- <view class="hairmsg-sex">性别：{{orderDetails?orderDetails.userGender == 1 ? "男" : "女"}}</view> -->
                        <view>
                            <image class="hairmsg-head" :src="orderDetails ? orderDetails.userPath : ''"></image>
                        </view>
                    </view>
                    <view class="code-shopmsg">
                        <view class="shopmsg-name flexbox-sb">
                            <text>接单美发师：</text>
                            <text class="color-9">{{ orderDetails?orderDetails.stylistname : '' }}</text>
                        </view>
                        <view class="shopmsg-sevrer flexbox-sb">
                            <text>服务项目：</text>
                            <text class="color-9">{{ orderDetails?orderDetails.ordername : '' }}</text>
                        </view>
                        <view class="shopmsg-num flexbox-sb">
                            <text>订单编号：</text>
                            <text class="color-9">{{ orderDetails?orderDetails.orderno : '' }}</text>
                        </view>
                        <view class="shopmsg-time flexbox-sb">
                            <text>预约时间：</text>
                            <text class="color-9">{{ orderDetails?orderDetails.ordertimeStr : '' }}</text>
                        </view>
                        <view class="shopmsg-money flexbox-sb">
                            <text>支付金额：</text>
                            <text class="color-r">￥{{ orderDetails?orderDetails.orderamount : '' }}</text>
                        </view>
                    </view>
                    <view class="onCodeReturn" @tap.stop.prevent="anewgetCode">重新扫描</view>
                    <view class="onCodeSuccess" @tap.stop.prevent="startOrder">完成订单</view>
                </view>
            </view>
        </van-overlay>

        <!-- 盲盒活动 -->
        <block v-if="isOver">
            <van-overlay :show="showFloat" :z-index="9999">
                <view class="wrapper">
                    <view class="wrapperbox">
                        <view class="centers" @tap.stop.prevent="mpsj">
                            <image v-if="!isColse" @tap="goDetail" class="headimg" mode="aspectFill" :src="imgs[0]">
                            </image>
                            <image v-else class="headimg" mode="aspectFill" :src="imgs[1]"></image>
                        </view>
                        <van-icon class="btn_close" name="close" @tap.native.stop.prevent="clickFloatClose" size="60rpx"
                            color="white" />
                    </view>
                </view>
            </van-overlay>
            <image class="btn_ft" @tap.stop.prevent="clickFloatBtn" :src="btnImg"></image>
        </block>
    </view>
</template>

<script>
//获取应用实例
var app = getApp();

const _request = require('../../utils/request.js'); // 引入require;

const moment = require('../../utils/moment.min');

var bgam = uni.createInnerAudioContext();
let lastClick = 0;
let isFirstLoad = false;
export default {
    data() {
        return {
            selected: 0,
            banners: [],
            pendingSum: '0',
            acceptAndServiceSum: '0',
            successSum: '0',
            refundSum: '0',
            shopimgUrl: app.globalData.shopimgUrl,
            show: false,

            //认证蒙层
            authtype: '',

            //1通过 0待审核 -1驳回 3未申请认证
            isRead: 1,

            //认证是否已读 1已读
            appletCheck: 0,

            // 审核状态
            showFloat: false,

            //是否弹出动画
            isColse: false,

            isOver: false,

            //是否显示盲盒活动
            imgs: [
                'https://yiyuestore.oss-cn-shenzhen.aliyuncs.com/2021-12-09/ce9238d8515a46598a79194a2dcaa2fb-files?id=' + Math.random(),
                'https://yiyuestore.oss-cn-shenzhen.aliyuncs.com/2021-12-09/e24a53bfb1d94a7d8e1c978fe69d59fd-files?id=' + Math.random()
            ],

            btnImg: 'https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/activityimage/icon_flow.png?id=' + Math.random(),
            countClick: 0,
            showoCode: false,

            // 核销弹窗
            // 核销信息
            orderDetails: null,

            orderId: ''
        };
    },
    onLoad: function (options) {
        uni.removeStorageSync('crm_storeId');
        console.log(options);
        let storeId = uni.getStorageSync('storeId');

        if (options.invitecode) {
            console.log(options.invitecode);
            uni.setStorageSync('code', options.invitecode); // 用户登录且没绑定用户的时候也需要自动绑定

            if (uni.getStorageSync('userId')) {
                _request
                    .postObj('/recomUser/bindInviteCode', {
                        userId: uni.getStorageSync('userId'),
                        invitecode: options.invitecode
                    })
                    .then((res) => {
                        uni.removeStorageSync('code');
                    });
            }
        }

        if (options.scene) {
            uni.setStorageSync('code', options.scene);
        }

        if (options.orderId || uni.getStorageSync('orderId')) {
            console.log(options, 'options.orderId');

            if (options.orderId) {
                uni.setStorageSync('orderId', options.orderId);
            }

            this.setData(
                {
                    orderId: options.orderId || uni.getStorageSync('orderId')
                },
                () => {
                    this.getOrder();
                }
            );
        } // 套餐包

        if (options.packageBag) {
            _request
                .get('/packageBag/getPackageBagInfoByStoreId', {
                    storeId: uni.getStorageSync('storeId'),
                    id: options.id
                })
                .then((res) => {
                    if (res.data.code === 200) {
                        uni.navigateTo({
                            url: '/pages/mealpage/cancel/index?id=' + options.id
                        });
                    } else if (res.data.message === '此套餐包不属于您的店') {
                        uni.showModal({
                            title: '此套餐包不属于您的店',
                            showCancel: false,
                            confirmText: '知道了',

                            success(res) {
                                if (res.confirm) {
                                } else if (res.cancel) {
                                }
                            }
                        });
                    }
                })
                .catch((error) => {
                    console.log(error, 'error');
                });
        }
    },
    onShow: function () {
        app.globalData.openTcp();
        this.getStoreOrderStatistical();
        this.getBanners();
        this.authentication(); //获取认证状态
        // 根据类型获取三端小程序审核状态  0待审核 1已审核

        _request
            .get(
                '/yy-data-conves/getAppletCheckByType',
                {
                    type: 1
                },
                app.globalData.mallType
            )
            .then((res) => {
                // console.log(res)
                if (res.data.code === 200) {
                    uni.setStorageSync('appletCheck', res.data.data.dval);
                    this.setData({
                        appletCheck: res.data.data.dval
                    });
                }
            });

        this.getActivityInfo();
        this.checkIsMaker();
    },
    methods: {
        // 切换到新首页
        switchNewHome() {
            uni.navigateTo({
                url: '/pageshop/index/index'
            });
        },

        goCheckstand() {
            _request
                .get('/cashier/getShops', {
                    storeId: uni.getStorageSync('storeId')
                })
                .then((res) => {
                    if (res.data.code == 200) {
                        uni.navigateTo({
                            url: '/pagesc/index/index'
                        });
                    } else {
                        uni.showModal({
                            title: '提示',
                            content: '您还没有创建门店',
                            success: function (res) {
                                if (res.confirm) {
                                    console.log('确定');
                                } else {
                                    console.log('取消');
                                }
                            }
                        });
                    }
                })
                .catch((error) => {
                    console.log(error, 'error');
                });
        },

        onCruiseShop() {
            uni.navigateTo({
                url: '/pagesc/cruiseshop/cruiseshop'
            });
        },

        //隐藏弹窗
        onClickCodeHide() {
            this.setData({
                showoCode: false
            });
        },

        // 重新扫描
        anewgetCode() {
            let vm = this;
            uni.scanCode({
                //扫描API
                success: function (res) {
                    if (res.path) {
                        vm.setData(
                            {
                                orderId: res.path.split('=')[1]
                            },
                            () => {
                                vm.getOrder();
                            }
                        );
                    } else {
                        uni.showToast({
                            title: '识别失败，请扫描正确的意约订单码',
                            icon: 'none',
                            duration: 1500
                        });
                    }
                },
                fail: function (res) {
                    uni.showToast({
                        title: '识别失败，请扫描正确的意约订单码',
                        icon: 'none',
                        duration: 1500
                    });
                }
            });
        },

        // 开始订单
        startOrder() {
            let vm = this;

            _request
                .postObj('/storeOrder/startOrder', {
                    orderId: this.orderId,
                    storeId: uni.getStorageSync('storeId')
                })
                .then((res) => {
                    if (res.data.code == 200) {
                        this.setData({
                            showoCode: false
                        });
                        let vm = this;
                        uni.showModal({
                            cancelText: '下一单',
                            confirmText: '确定',
                            content: '点击确定跳转至已完成订单页，点击下一单可进行下一单扫码核验',
                            success: (result) => {
                                if (result.confirm) {
                                    // wx.showToast({
                                    //   title: '核销成功',
                                    //   icon: 'none',
                                    //   duration: 1000
                                    // })
                                    setTimeout(() => {
                                        const orderId = vm.orderId;
                                        const statusRemark = vm.orderDetails.statusRemark;
                                        const orderBtn = vm.orderDetails.orderBtn;
                                        const mealName = vm.orderDetails.mealName; // 查询订单详情

                                        uni.navigateTo({
                                            url:
                                                '/pages/orderdetail/orderdetail?orderId=' + orderId + '&orderStatus=' + '已完成' + '&orderBtn=' + orderBtn + '&mealName=' + mealName
                                        });
                                    }, 1000);
                                } else if (result.cancel) {
                                    vm.getcode();
                                }
                            }
                        });
                    } else {
                        uni.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                })
                .catch((error) => {
                    console.log(error, 'error');
                });
        },

        // wx扫码
        getwxCode(orderId) {
            let vm = this;
            uni.showModal({
                cancelText: '重新扫描',
                confirmText: '确认核销',
                content: '请确认是否核销该订单？',
                success: (result) => {
                    if (result.confirm) {
                        vm.startOrder(orderId);
                    } else if (result.cancel) {
                        vm.getcode();
                    }
                }
            });
        },

        // 获取订单信息
        getOrder() {
            _request
                .get('/order/getOrder', {
                    orderId: this.orderId
                })
                .then((res) => {
                    if (res.data.code == 200) {
                        uni.removeStorageSync('orderId');
                        this.setData({
                            showoCode: true,
                            isOver: false,
                            orderDetails: { ...res.data.data, orderamount: res.data.data.orderamount.toFixed(2), ordertimeStr: this.getYMDHMS(res.data.data.ordertime) }
                        });
                    }
                })
                .catch((error) => {
                    console.log(error, 'error');
                });
        },

        getYMDHMS(timestamp) {
            if (!timestamp) {
                return '';
            }

            let time = new Date(timestamp);
            let year = time.getFullYear();
            let month = time.getMonth() + 1;
            let date = time.getDate();
            let hours = time.getHours();
            let minute = time.getMinutes();
            let second = time.getSeconds();

            if (month < 10) {
                month = '0' + month;
            }

            if (date < 10) {
                date = '0' + date;
            }

            if (hours < 10) {
                hours = '0' + hours;
            }

            if (minute < 10) {
                minute = '0' + minute;
            }

            if (second < 10) {
                second = '0' + second;
            }

            return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second;
        },

        // 扫码
        getcode() {
            let vm = this;
            uni.scanCode({
                //扫描API
                success: function (res) {
                    console.log('scanCode: ', res);

                    if (res.result && (!res.path || res.path.indexOf('packageBag') < 0)) {
                        let parms = res.result.split('&');
                        const orderSn = parms[0]?.split('=')[1] || '';
                        const userId = parms[1]?.split('=')[1] || '';
                        const orderId = res.path?.split('=')[1];

                        if (orderSn) {
                            uni.navigateTo({
                                url: '/pages/mallorder/orderinfo?cancel=' + 'true' + '&orderSn=' + orderSn + '&userId=' + userId + '&bool=' + true + '&cancel=' + 'true'
                            });
                        } else if (orderId) {
                            //扫描用户服务订单核销
                            vm.setData(
                                {
                                    orderId: res.path.split('=')[1],
                                    isOver: false
                                },
                                () => {
                                    vm.getOrder();
                                }
                            );
                        } else {
                            uni.showToast({
                                title: '识别失败，请扫描正确的核销码',
                                icon: 'none',
                                duration: 1500
                            });
                        }
                    } else if (res.path) {
                        if (res.path.indexOf('packageBag') > -1) {
                            const id = res.path.split('=')[1].split('&')[0];
                            console.log(id);

                            _request
                                .get('/packageBag/getPackageBagInfoByStoreId', {
                                    storeId: uni.getStorageSync('storeId'),
                                    id
                                })
                                .then((res) => {
                                    if (res.data.code === 200) {
                                        uni.navigateTo({
                                            url: '/pages/mealpage/cancel/index?id=' + id
                                        });
                                    } else if (res.data.message === '此套餐包不属于您的店') {
                                        uni.showToast({
                                            title: res.data.message,
                                            icon: 'none',
                                            duration: 2000
                                        });
                                    }
                                })
                                .catch((error) => {
                                    console.log(error, 'error');
                                });
                        } else {
                            vm.setData(
                                {
                                    orderId: res.path.split('=')[1],
                                    isOver: false
                                },
                                () => {
                                    vm.getOrder();
                                }
                            );
                        }
                    } else {
                        uni.showToast({
                            title: '识别失败，请扫描正确的核销码',
                            icon: 'none',
                            duration: 1500
                        });
                    }
                },
                fail: function (res) {
                    uni.showToast({
                        title: '识别失败，请扫描正确的核销码',
                        icon: 'none',
                        duration: 1500
                    });
                }
            });
        },

        // 前往详情
        toDetails(e) {
            const { item } = e.currentTarget.dataset; // console.log('----->', item);
            //banner点击次数

            uni.request({
                url: app.globalData.baseurl + app.globalData.mallPrefix + '/banner/increaseClicks',
                method: 'POST',
                data: {
                    id: item.id
                },
                header: {
                    'Content-Type': 'application/json',
                    token: uni.getStorageSync('token')
                },
                success: function (res) { },
                fail: function (res) {
                    console.log(res);
                }
            });

            if (item.category == 2 && item.productSn) {
                //跳转商品详情
                uni.navigateTo({
                    url: '/shopingmall/goodsdetail/goodsdetail?productsn=' + item.productSn
                });
                return;
            }

            if (item.category == 3 && item.url) {
                if (item.url == '/firstpages/shopping/index') {
                    //商城
                    uni.switchTab({
                        url: item.url
                    });
                    return;
                }

                if (item.url == 'blind_box') {
                    //盲盒
                    if (this.isOver) {
                        uni.navigateTo({
                            url: '/pagesb/activity/detail'
                        });
                    }

                    return;
                }

                if (item.url === '/pages/maker/makerdetails/index') {
                    //拓客卡
                    let isMaker = uni.getStorageSync('maker')?.ismaker || false;

                    if (isMaker) {
                        uni.navigateTo({
                            url: item.url
                        });
                    } else {
                        uni.navigateTo({
                            url: '/pages/maker/buymaker/index'
                        });
                    }

                    return;
                }

                uni.navigateTo({
                    url: item.url
                });
            }

            if (item.category == 4 && item.url) {
                uni.navigateTo({
                    url: '/pagesb/webpage/index?url=' + encodeURIComponent(item.url)
                });
            }
        },

        authentication() {
            _request
                .get('/storeAuthApply/getStoreAuthStatusByStoreId', {
                    storeId: uni.getStorageSync('storeId') || 0
                })
                .then((res) => {
                    if (res.data.code == 200) {
                        this.setData({
                            authtype: res.data.data.status,
                            isRead: res.data.data.isRead
                        });
                        uni.setStorageSync('authtype', res.data.data.status);

                        if (this.authtype == 3) {
                            var that = this;
                            uni.showModal({
                                title: '您还未进行信息认证',
                                content: '为了完整的进行体验，请先完成信息认证再进行操作。',
                                cancelText: '暂不认证',
                                confirmText: '立即认证',

                                success(res) {
                                    if (res.confirm) {
                                        that.goauthindex();
                                    }
                                }
                            });
                        }

                        if (this.isRead != 1 && (this.authtype == 0 || this.authtype == 1 || this.authtype == -1)) {
                            this.setData({
                                show: true
                            });
                        } else {
                            this.setData({
                                show: false
                            });
                        }
                    } else {
                        uni.showToast({
                            title: res.data.message,
                            icon: 'none'
                        });
                    }
                });
        },

        // 修改阅读状态
        onisRead() {
            _request
                .get('/storeAuthApply/readApply', {
                    storeId: uni.getStorageSync('storeId')
                })
                .then((res) => { })
                .catch((error) => {
                    console.log(error, 'error');
                });
        },

        getshow() {
            this.setData({
                show: !this.show
            }); // 修改阅读状态

            this.onisRead();
        },

        goauthindex() {
            uni.navigateTo({
                url: '/pages/auth/index'
            });
        },

        // getauthbaseindex() {
        //   wx.showToast({
        //     title: '品牌商品入驻中,尽情期待！',
        //     icon:'none'
        //   })
        //   return;
        //   wx.navigateTo({
        //     url: '/pages/auth/base/index',
        //   })
        // },
        //获取banner信息
        //`type` ： '轮播位置：1->首页轮播；2->我的轮播；4->商城首页轮播；5->意豆商城； 6->创客大礼包；7->商品分类（joinId必填，关联商品分类表id）',
        //`roles` ： '显示端口：1用户端、2美发师端、3门店端，多个逗号隔开',
        getBanners: function () {
            _request
                .get(
                    '/banner/getList',
                    {
                        type: 1,
                        roles: 3
                    },
                    app.globalData.mallType
                )
                .then((res) => {
                    if (res.data.code === 200) {
                        this.setData({
                            banners: res.data.data || []
                        });
                    }
                })
                .catch((error) => {
                    console.log(error, 'error');
                });
        },

        // 获取门店订单信息
        getStoreOrderStatistical() {
            _request
                .get('/store/getStoreOrderStatistical', {
                    storeId: uni.getStorageSync('storeId') || 0
                })
                .then((res) => {
                    this.setData({
                        pendingSum: res.data.data.pendingSum,
                        acceptAndServiceSum: res.data.data.acceptAndServiceSum,
                        successSum: res.data.data.successSum,
                        refundSum: res.data.data.refundSum
                    });
                })
                .catch((error) => {
                    console.log(error, 'error');
                });
        },

        onOrderListTap: function (event) {
            var orderStatus = event.currentTarget.dataset.orderStatus;
            uni.navigateTo({
                url: '/pages/orderlist/index?orderStatus=' + orderStatus
            });
        },

        onOrderTap: function () {
            uni.navigateTo({
                url: '/pages/order/index'
            });
        },

        onSeatTap: function () {
            uni.navigateTo({
                url: '/pages/seat/index'
            });
        },

        onEvaluationTap: function () {
            uni.navigateTo({
                url: '/pages/evaluation/index'
            });
        },

        onMealTap: function () {
            uni.navigateTo({
                url: '/pages/mealpage/index'
            });
        },

        onPersonTap: function () {
            uni.navigateTo({
                url: '/pages/person/index'
            });
        },

        onMarketTap: function () {
            uni.navigateTo({
                url: '/pages/market/index'
            });
        },

        onTimeTap: function () {
            uni.navigateTo({
                url: '/pages/time/index'
            });
        },

        onInvitationTap: function () {
            uni.navigateTo({
                url: '/pages/invite/index'
            });
        },

        onShopManagerTap: function () {
            uni.navigateTo({
                url: '/pages/shopmanager/index'
            });
        },

        onMyStylistsTap: function () {
            uni.navigateTo({
                url: '/pages/my_stylists/my_stylists'
            });
        },

        // 是否创客
        checkIsMaker() {
            _request
                .get('/maker/checkIsMaker', {
                    userId: uni.getStorageSync('userid')
                })
                .then((res) => {
                    uni.setStorageSync('maker', res.data.data);
                })
                .catch((error) => {
                    console.log(error, 'error');
                });
        },

        //获取临时活动是否显示
        getActivityInfo() {
            _request
                .get(
                    '/mall-activity/getActivityType',
                    {
                        type: '1'
                    },
                    app.globalData.mallType
                )
                .then((res) => {
                    if (res.data.code === 200) {
                        app.globalData.isOver = res.data.data?.isOver;
                        this.setData({
                            isOver: res.data.data?.isOver
                        });

                        if (!isFirstLoad) {
                            this.showActivity();
                            isFirstLoad = true;
                        }
                    }
                });
        },

        //--------盲盒活动---------
        clickFloatBtn() {
            let that = this;
            that.setData({
                imgs: [
                    'https://yiyuestore.oss-cn-shenzhen.aliyuncs.com/2021-12-09/ce9238d8515a46598a79194a2dcaa2fb-files?' + new moment().valueOf(),
                    'https://yiyuestore.oss-cn-shenzhen.aliyuncs.com/2021-12-09/e24a53bfb1d94a7d8e1c978fe69d59fd-files?' + new moment().valueOf()
                ],
                showFloat: true
            });
            bgam.src = 'https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/activityimage/coin.mp3';
            bgam.play();
        },

        clickFloatClose() {
            if (new moment().valueOf() - lastClick < 3000) {
                return;
            }

            lastClick = new moment().valueOf();
            this.setData({
                isColse: true
            });
            bgam.src = 'https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/activityimage/click.mp3';
            bgam.play();
            let that = this;
            setTimeout(function () {
                that.setData({
                    imgs: ['', ''],
                    showFloat: false,
                    isColse: false
                });
                bgam.pause();
            }, 500);
        },

        goDetail() {
            let that = this;

            if (new moment().valueOf() - lastClick < 3000) {
                return;
            }

            lastClick = new moment().valueOf();
            bgam.src = 'https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/activityimage/click.mp3';
            bgam.play();
            setTimeout(function () {
                that.setData({
                    imgs: ['', ''],
                    showFloat: !that.showFloat,
                    isColse: false
                });
                uni.navigateTo({
                    url: '../../pagesb/activity/detail'
                });
                bgam.pause();
            }, 500);
        },

        //是否显示悬浮活动
        showActivity() {
            if (this.isOver) {
                this.setData({
                    showFloat: true
                });
                bgam.src = 'https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/activityimage/coin.mp3';
                setTimeout(function () {
                    bgam.play();
                }, 1500);
            }
        },

        onSwiperTap() {
            console.log('占位：函数 onSwiperTap 未声明');
        },

        shop() {
            console.log('占位：函数 shop 未声明');
        },

        mpsj() {
            console.log('占位：函数 mpsj 未声明');
        }
    }
};
</script>
<style>
/* 旧版 */
.home_tip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.mantle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 470rpx;
    background-color: rgb(0, 0, 0, 0.7);
}

.mantle_btn {
    border: 1px solid #ffffff;
}

swiper {
    top: 60rpx;
    width: 100%;
    height: 470rpx;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

swiper image {
    width: 100%;
    height: 470rpx;
}

.wx-swiper-dots.wx-swiper-dots-horizontal {
    margin-bottom: 80rpx;
}

.home_order {
    width: 708rpx;
    height: 180rpx;
    margin-left: 22rpx;
    margin-right: 20rpx;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-direction: row;
    border-radius: 10rpx;
    position: relative;
    top: -80rpx;
}

.home_order_1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    align-content: center;
    justify-content: center;
    margin: 20rpx;
}

.index-title {
    color: #333;
    font-size: 40rpx;
    font-weight: 900;
}

.index-content {
    color: #666;
    font-size: 32rpx;
    margin-top: 10rpx;
}

.home_list {
    position: relative;
    top: -80rpx;
    padding: 0 30rpx;
    padding-bottom: 80rpx;
    text-align: center;
}

.home_row {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-content: center;
    justify-content: space-between;
}

.home_hair {
    width: 320rpx;
    height: 380rpx;
    background-color: #ff8722;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-content: center;
    justify-content: center;
    margin: 10rpx;
    border-radius: 20rpx;
}

.home_hair text {
    color: #ffffff;
    font-size: 36rpx;
    font-weight: 500;
}

.home_hair image {
    margin-top: 40rpx;
    width: 190rpx;
    height: 182rpx;
}

.home_hair1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    align-content: center;
    justify-content: center;
}

.home_shop {
    width: 300rpx;
    height: 180rpx;
    display: flex;
    flex-direction: row;
    align-items: center;
    align-content: center;
    justify-content: space-between;
    margin: 10rpx;
    border-radius: 10rpx;
    padding-left: 20rpx;
}

.home_ordermanage {
    width: 320rpx;
    height: 180rpx;
    background-color: #e5f8f6;
    display: flex;
    flex-direction: row;
    align-items: center;
    align-content: center;
    justify-content: space-between;
    margin: 10rpx;
    border-radius: 10rpx;
}

.home_shop text {
    color: #333333;
    font-size: 36rpx;
    font-weight: 500;
    margin-left: 20rpx;
}

.home_shop image {
    width: 80rpx;
    height: 90rpx;
    margin-right: 20rpx;
}

.home_shop1 {
    display: flex;
    flex-direction: column;
    align-content: center;
    justify-content: center;
}

.home_ordermanage text {
    color: #333333;
    font-size: 36rpx;
    font-weight: 500;
    margin-left: 20rpx;
}

.home_ordermanage image {
    width: 80rpx;
    height: 90rpx;
    margin-right: 20rpx;
}

.home_row1 {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    justify-content: space-between;
}

page {
    background-color: #fbfbfb;
}

.page-wrap {
    position: relative;
}

/* 盲盒 */
.wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
}

.wrapperbox {
    width: 750rpx;
    display: flex;
    justify-content: center;
    height: 911rpx;
    top: -100rpx;
    position: relative;
}

.headimg {
    width: 720rpx;
    height: 640rpx;
}

.btn_ft {
    position: fixed;
    /* z-index: 99; */
    width: 112rpx;
    height: 136rpx;
    bottom: 120rpx;
    right: 20rpx;
}

.btn_close {
    position: absolute;
    width: 82rpx;
    height: 82rpx;
    bottom: 16rpx;
    left: calc(50% - 41rpx);
}

/* 核销 */
.codebox {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
}

.codewrapperbox {
    width: 670rpx;
    height: 828rpx;
    background: #ffffff;
    box-shadow: 2px 2px 8px 2px rgba(226, 226, 226, 0.4);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    position: relative;
}

.code-hairmsg {
    width: 630rpx;
    height: 200rpx;
    background: #f7f7f7;
    border-radius: 8px;
    position: absolute;
    top: 40rpx;
    padding: 0 20rpx;
    box-sizing: border-box;
}

.hairmsg-name {
    font-size: 36rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
    line-height: 50rpx;
    position: absolute;
    /* top: 44rpx; */
    top: 80rpx;
    max-width: 440rpx;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
}

.hairmsg-head {
    width: 140rpx;
    height: 140rpx;
    position: absolute;
    border-radius: 50%;
    right: 20rpx;
    top: 30rpx;
}

.hairmsg-sex {
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #666666;
    line-height: 40rpx;
    position: absolute;
    top: 114rpx;
}

.code-shopmsg {
    width: 630rpx;
    height: 400rpx;
    background: #f7f7f7;
    border-radius: 8px;
    position: absolute;
    top: 260rpx;
    padding: 0 20rpx;
    box-sizing: border-box;
}

.shopmsg-name {
    position: absolute;
    font-size: 28rpx;
    width: 590rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 40rpx;
    top: 40rpx;
}

.shopmsg-sevrer {
    position: absolute;
    font-size: 28rpx;
    width: 590rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 40rpx;
    top: 100rpx;
}

.shopmsg-num {
    position: absolute;
    font-size: 28rpx;
    width: 590rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 40rpx;
    top: 160rpx;
}

.shopmsg-time {
    position: absolute;
    font-size: 28rpx;
    width: 590rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 40rpx;
    top: 220rpx;
}

.shopmsg-money {
    position: absolute;
    font-size: 28rpx;
    width: 590rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 40rpx;
    top: 280rpx;
}

.color-9 {
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #666666;
    max-width: 400rpx;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
}

.color-r {
    font-size: 32rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #fa1818;
}

.onCodeReturn {
    width: 280rpx;
    height: 88rpx;
    background: #ff8722;
    border-radius: 44px;
    font-size: 36rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #ffffff;
    line-height: 88rpx;
    text-align: center;
    position: absolute;
    bottom: 40rpx;
    left: 20rpx;
}

.onCodeSuccess {
    width: 280rpx;
    height: 88rpx;
    border-radius: 44px;
    border: 2px solid #ff8722;
    font-size: 36rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 50;
    color: #ff8722;
    line-height: 88rpx;
    text-align: center;
    position: absolute;
    bottom: 40rpx;
    right: 20rpx;
}

.switch-versions {
    position: relative;
}

.switch-versions-iamge {
    height: 74rpx;
}

.switch-versions .switch {
    position: absolute;
    font-size: 24rpx;
    right: 64rpx;
    top: 48%;
    transform: translateY(-50%);
    color: #e94a18;
}

/* 新版 */

.page-wrap {
    background-color: #fff;
    height: 100%;
    position: relative;
}

/* 头部功能列表部分 */
.nav-list {
    height: 180rpx;
    display: flex;
    background-color: #fff;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.nav-box {
    box-shadow: 0px 0px 14px 0px rgba(102, 102, 102, 0.12);
    background-color: #fff;
    border-radius: 10rpx;
    width: 222rpx;
    height: 120rpx;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.nav-icon {
    width: 64rpx;
    height: 64rpx;
}

.nav-text {
    color: #333;
    font-size: 26rpx;
}

/* 门店经营 */
.store-operation {
    margin: 20rpx 0;
    background-color: #fff;
    position: absolute;
    border-top: 20rpx solid #f1f1f1;
}

.title-box {
    display: flex;
    align-items: center;
    padding: 40rpx;
    border-bottom: 0.5px solid #e5e5e5;
}

.title-spot {
    width: 8rpx;
    height: 8rpx;
    background-color: #e94a18;
    border-radius: 50%;
    margin-right: 8rpx;
}

.title-text {
    font-size: 30rpx;
}

/* 门店经营下面的图标部分 */
.manage-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
}

.manage-box {
    margin: 30rpx 40rpx;
}

.manage-icon-wrap {
    box-shadow: 0px 0px 10px 0px rgba(211, 51, 1, 0.1);
    background-color: #fff;
    border-radius: 10rpx;
    height: 94rpx;
    width: 94rpx;
    margin-bottom: 6rpx;
}

.manage-icon-iamge {
    width: 50rpx;
    height: 50rpx;
    margin: 22rpx 0 0 22rpx;
    /* border: 1px solid red; */
}

.manage-text {
    font-size: 26rpx;
}

.switch-versions-iamge {
    position: relative;
    margin: 40rpx 0;
    width: 670rpx;
    height: 74rpx;
}

.switch {
    position: absolute;
    font-size: 24rpx;
    right: 58rpx;
    top: 22rpx;
    color: #e94a18;
}
</style>
